#!/bin/csh -f
if(! -f mktm.def) then
    echo "File mktm.def must be present in the curdir"
    exit
endif
set rn=`awk '$1=="rootname"{print $2}' mktm.def`
set nt=`tail -1 $rn".sel.erep"|awk '{print $2}'`
set out=$rn".M"
head -3 $rn".M1" | awk 'BEGIN{nt=ARGV[1];ARGV[1]="-"}FNR==3{nn=$1;mu=$2}FNR<3{b=b$0"\n"}END{print nn,mu,nt"  # mgroup";printf b}' $nt > $out
@ i = 1
while( $i <= $nt )
    awk 'FNR>3' $rn".M"$i >> $out
    @ i++
end
##
